
	var btns = document.getElementsByTagName("button");
	for(var i = 0; i < btns.length; i++){
		btns[i].onclick = function(event){
			
		}
	}
	var login_top = document.querySelector(".login-top");
	var form = document.getElementById("form");
	var spans = login_top.getElementsByTagName("span");
	var divs = form.getElementsByTagName("div");
	for(var i = 0; i < spans.length; i++){
		spans[i].index = i;
		spans[i].onclick = function(){
			for(var j = 0; j < spans.length; j++){
				spans[j].className = "";
				divs[j].style.display = "none";
			}
			spans[this.index].className = "red-color";
			divs[this.index].style.display = "block";
		}
	}
	var inputs = form.getElementsByTagName("input");
	var login = document.getElementById("login");
	var reg_user = /^[a-zA-z]\w{7,15}$/;
	var reg_pass = /^[/w$#@%^&*,.!]$/;
	login.onclick = function(event){
		event.preventDefault();
		if(inputs[0].value === "" || inputs[1].value ===""){
			alert("账号与密码不能为空\n至少8位数，开头不能为数字");
			return;
		}
		if(inputs[0].value.trim() === "" || !reg_user.test(inputs[0].value)){
			alert("请输入正确的格式");
			return;
		}
		var user_info = get_localStorage("user_info");
		if(user_info){
			for(var i = 0; i < user_info.length; i++){
	    		if(inputs[0].value === user_info[i].user && inputs[1].value === user_info[i].password){
	    			var login_info = {
	    				name:inputs[0].value,
	    				password:inputs[1].value
	    			}
	    			
	    			location.href = "index.html";
	    			inputs[0].value = "";
					inputs[1].value = "";
					
					document.cookie = "name=login";
	    			break;
	    		}else if(inputs[0].value !== user_info[i].user){
	    			alert("用户不存在，请先去注册");
	    			inputs[0].value = "";
					inputs[1].value = "";
	    			break;
	    		}else if(inputs[1].value !== user_info[i].password){
	    			alert("账号或密码错误");	
	    		}
    		}
		}else {
			alert("用户不存在，请先去注册");
			inputs[0].value = "";
			inputs[1].value = "";
		}
	}

